package com.acme.bankapp.domain.bank;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class Bank {
	private ArrayList<Client> clients = new ArrayList<>();
	private ClientRegisrationListener[] listeners = new ClientRegisrationListener[2];
	
	Bank(){			
		
		class PrintClientListener implements ClientRegisrationListener{
				
			public void onClientAdded(Client c){
				final SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy hh:mm");
				c.getClientSalutation();
				System.out.println(": " + "add at " + formatter.format(new Date()));
			}			
		}
			
		class EmailNotificationListener implements ClientRegisrationListener{
				
			public void onClientAdded(Client c){
				System.out.print("Notification email for client ");
				c.getClientSalutation();
				System.out.println(" to be send");
			}			
		}
		listeners[0] = new PrintClientListener();
		listeners[1] = new EmailNotificationListener();
	}		
	
	Bank(ClientRegisrationListener ... listeners){
		this.listeners = listeners;
	}
		
		public ArrayList<Client> getClients(){
			return clients;
		}
		
		public void setClients(Client client){
			clients.add(client);
		}
		
		public ClientRegisrationListener[] getListeners(){
			return listeners;
		}
}
